package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.stockTestPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:stockTestMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2025/1/21 17:12
 * @Version 1.0
 */
@Mapper
public interface stockTestMapp {
    //插入一行作业指导书
    @DS("russianEngine")
    @Insert("insert into partTestList (" +
            "establishTime, updateTime, deleteSign, " +
            "editName, drawing, project, " +
            "requirement, testType, ceiling, " +
            "lower, standard, frequency, " +
            "department, orderNumber, partType," +
            "partName)" +
            " VALUES (" +
            "#{establishTime},#{updateTime},#{deleteSign}," +
            "#{editName},#{drawing},#{project}," +
            "#{requirement},#{testType},#{ceiling}," +
            "#{lower},#{standard},#{frequency}," +
            "#{department},#{orderNumber},#{partType},#{partName})")
    void insertOneWorkData(stockTestPojo stockTestPojo);
    //根据一个字段，查询等于这个值的所有信息，查询的是字符串类型。
    @DS("russianEngine")
    @Select("select drawing, MAX(partName) as partName from partTestList where ${filedName}=#{filedVal} GROUP BY drawing;")
    List<stockTestPojo> inquiryOneFiled(String filedName, String filedVal);
    //查询等于这两个字段的所有数据
    @DS("russianEngine")
    @Select("select * from partTestList where ${fistFiledName}=#{fistFiledVal} and ${secondFiledName}=#{secondFiledVal} and deleteSign=1")
    List<stockTestPojo> inquiryTwoFiledAll(String fistFiledName, String fistFiledVal, String secondFiledName, String secondFiledVal);
    //修改一行所有的数据
    @DS("russianEngine")
    @Update("update partTestList set " +
            "establishTime=#{establishTime}, " +
            "updateTime=#{updateTime}, " +
            "deleteSign=#{deleteSign}, " +
            "editName=#{editName}, " +
            "partName=#{partName}, " +
            "drawing=#{drawing}, " +
            "project=#{project}, " +
            "requirement=#{requirement}, " +
            "testType=#{testType}, " +
            "ceiling=#{ceiling}, " +
            "lower=#{lower}, " +
            "standard=#{standard}, " +
            "frequency=#{frequency}, " +
            "orderNumber=#{orderNumber}, " +
            "partType=#{partType}, " +
            "department=#{department} " +
            "where id=#{id}")
    void stockTestEditOneAll(stockTestPojo stockTestPojo);
    //根据id，修改一个字段
    @DS("russianEngine")
    @Update("update partTestList set ${filedName}=#{filedVal} where id=#{id}")
    void editOneFiled(Integer id, String filedName, int filedVal);
}
